Optical sensor, electronic device, distance calculation method, and storage medium of program

ABSTRACT

An optical sensor comprises a light-emitting element configured to emit light in a region where an object is present; a light-receiving element configured to receive reflected light from the object; a generation unit configured to generate a histogram indicating a relationship between a time from emission of the light by the light-emitting element to reception of the reflected light by the light-receiving element and an intensity of the reflected light received by the light-receiving element; a first calculation unit configured to calculate skewness of the histogram; and a second calculation unit configured to calculate a distance between the optical sensor and the object with reference to the histogram and the skewness.

CROSS-REFERENCE TO RELATED APPLICATION

The present application claims priority from Japanese ApplicationJP2021-072082, the content of which is hereby incorporated by referenceinto this application.

BACKGROUND 1. Field

An aspect of the present disclosure relates to an optical sensor, anelectronic device, a distance calculation method, and a storage mediumof a program.

In distance calculation of a target object by a time of flight (ToF)sensor, as an example, reflected light is counted by a time to digitalconverter (TDC) circuit for each time period from emission of light toreception of the reflected light from a target object (time of flight oflight), and the TCD circuit generates a histogram. Then, the distancefrom the sensor to the target object is calculated using a time at whichthe count is a maximum among the time of flight of light.

For example, JP 6709335 B discloses a method of using a sensor cover tosubtract a crosstalk component or a disturbance light component otherthan a reflected light component of the target object. Specifically, inorder to improve measurement time, which accompanies improvement of theresolution of a camera, the distance from the sensor to the targetobject is determined by calculating reflected light in which a pulsedlight emitted from a light-emitting element is reflected by the targetobject and is incident on a first light receiving unit and referencelight in which the pulsed light emitted from the light-emitting elementis directly incident on a second light receiving unit (crosstalk insidethe sensor). In this way, by subtracting the reference light componentfrom the reflected light component, accuracy of the reflected lightcomponent is improved.

SUMMARY

However, in the known art, there is a problem in that in a case wherereflected light components from a plurality of target objects are mixedin a histogram, distance calculation accuracy of one target objectcannot be improved. This is because, even when the reflected light andthe reference light is calculated, in a case where an object other thanthe target object (hereinafter referred to as a “non-target object”) ispresent around the target object, the reflected light from thenon-target object mixes with the reflected light from the target object,and thus the distance to the target object cannot be accuratelycalculated.

An aspect of the present disclosure is to calculate distance to a targetobject with high accuracy even when a non-target object is presentaround the target object.

In order to solve the problem described above, an optical sensoraccording to an aspect of the present disclosure includes alight-emitting element configured to emit light in a region where anobject is present, a light-receiving element configured to receivereflected light from the object, a generation unit configured togenerate a histogram indicating a relationship between a time fromemission of the light by the light-emitting element to reception of thereflected light by the light-receiving element and an intensity of thereflected light received by the light-receiving element, a firstcalculation unit configured to calculate skewness of the histogram, anda second calculation unit configured to calculate a distance between theoptical sensor and the object with reference to the histogram and theskewness.

Furthermore, a distance calculation method according to an aspect of thepresent disclosure is the distance calculation method for an opticalsensor for measuring a distance to an object, the optical sensorincluding a light-emitting element configured to emit light in a regionwhere the object is present and a light-receiving element configured toreceive a reflected light from the object, wherein the distancecalculation method includes generating a histogram indicating arelationship between a time from emission of the light by thelight-emitting element to reception of the reflected light by thelight-receiving element and an intensity of the reflected light receivedby the light-receiving element, performing a first calculation ofcalculating skewness indicating a degree of distortion from a normaldistribution of the histogram generated in the generating of thehistogram, and performing a second calculation of correcting thehistogram generated in the generating of the histogram by using theskewness calculated in the first calculation and calculating a distancebetween the optical sensor and the object from the histogram.

According to an aspect of the present disclosure, distance to a targetobject can be calculated with high accuracy.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram illustrating a configuration of an opticalsensor according to a first embodiment of the present disclosure.

FIG. 2 is a graph showing examples of histograms according to the firstembodiment of the present disclosure.

FIG. 3 is a flowchart illustrating processing of the optical sensoraccording to the first embodiment of the present disclosure.

FIG. 4 is a graph showing a specific example according to the firstembodiment of the present disclosure.

FIG. 5 is a graph showing histograms of distances between an opticalsensor and a target object and between the optical sensor and anon-target object according to a second embodiment of the presentdisclosure.

FIG. 6 is a flowchart illustrating processing of the optical sensoraccording to the second embodiment of the present disclosure.

FIG. 7 is a graph showing a specific example of the second embodiment ofthe present disclosure.

FIG. 8 is a block diagram illustrating a configuration of an opticalsensor according to a third embodiment of the present disclosure.

FIG. 9 is a block diagram illustrating a configuration of an opticalsensor according to a sixth embodiment of the present disclosure.

FIG. 10 is a graph showing a change in a signal amount detected by theoptical sensor due to a difference in distance according to the sixthembodiment of the present disclosure.

FIG. 11 is a flowchart illustrating processing of the optical sensoraccording to the sixth embodiment of the present disclosure.

FIG. 12 is a graph showing a specific example of the sixth embodiment ofthe present disclosure.

DESCRIPTION OF EMBODIMENTS First Embodiment

A first embodiment of the present disclosure will be described in detailbelow.

Configuration of Optical Sensor 1

FIG. 1 is a block diagram illustrating a configuration of an opticalsensor 1 according to the present embodiment. The optical sensor 1 is aToF sensor configured to measure distance to an object based on a timefrom emission of light to reception of reflected light from the object.

As illustrated in FIG. 1, the optical sensor 1 includes a referencepulse generation unit 11, a driver 12, a light-emitting element 13, asignal light receiving unit (light-receiving element) 21, a first TDC22, a reference light receiving unit (light-receiving element) 23, asecond TDC 24, a histogram generation unit (generation unit) 25, and acalculation unit (first calculation unit and second calculation unit)26.

The reference pulse generation unit 11 supplies a reference pulse havinga wave shape to the driver 12. The reference pulse generation unit 11supplies a reference clock signal to the first TDC 22 and the second TDC24.

The driver 12 causes the light-emitting element 13 to emit a pulsedlight based on the reference pulse from the reference pulse generationunit 11. The light-emitting element 13 emits light in a region where atarget object (object) 2 is present. The pulsed light emitted from thelight-emitting element 13 is reflected by each of the target object 2and a non-target object 3 and is incident on the signal light receivingunit 21. The pulsed light emitted from the light-emitting element 13 isdirectly incident on the reference light receiving unit 23. Hereinafter,light that is directly incident on the reference light receiving unit 23is referred to as “reference light”.

The signal light receiving unit 21 is a light-receiving element forreceiving reflected light from the target object 2 and the non-targetobject 3, and outputs a pulse that is synchronized with respect to thereflected light from the target object 2 and the non-target object 3 tothe first TDC 22. The first TDC 22 outputs a time stamp indicating apulse output time of the pulse output by the signal light receiving unit21 to the histogram generation unit 25.

The reference light receiving unit 23 outputs a pulse that issynchronized with respect to the reference light from the light-emittingelement 13 to the second TDC 24. The second TDC 24 outputs a time stampindicating a pulse output time of the pulse output by the referencelight receiving unit 23 to the histogram generation unit 25.

The histogram generation unit 25 generates a histogram indicating arelationship between a time from emission of the light by thelight-emitting element 13 to reception of the reflected light by thesignal light receiving unit 21 and an intensity of the reflected lightreceived by the signal light receiving unit 21. Specifically, thehistogram generation unit 25 receives the time stamp from the first TDC22 and increases a count value in a bin serving as a measurementinterval corresponding to the time stamp. Then, the histogram generationunit 25 counts the time stamp in a predetermined cycle and generates ahistogram based on the count. The histogram generation unit 25 receivesthe time stamp also from the second TDC 24 and performs processingsimilar to that described above to generate a histogram. Note that theintensity of the reflected light is proportional to the count value inthe bin.

Among the histograms generated by the histogram generation unit 25, aposition of the center of gravity of the histogram based on the timestamp from the second TDC 24 is set as a origin with respect to thehistogram based on the time stamp from the first TDC 22, and thecalculation unit 26 calculates a detection distance from a differencebetween the position of the center of gravity of the former histogramand the position of the center of gravity of the latter histogram.

Subsequently, the calculation unit (first calculation unit) 26calculates skewness indicating a degree of distortion from a normaldistribution of the above-described histogram which is set as theorigin. Then, the calculation unit (second calculation unit) 26calculates a distance between the optical sensor 1 and the target object2 with reference to the histograms generated by the histogram generationunit 25 and the calculated skewness.

Note that the optical sensor 1 may output data of the calculateddistance to another device located a short distance away (for example, amemory on the same substrate) by inter-integrated circuit (I2C)communication.

FIG. 2 is a graph showing examples of histograms according to thepresent embodiment. Since the optical sensor 1 has the above-describeddistance detection mechanism, in a case where the non-target object 3,which is an object other than the target object 2, is also presentwithin the sensing range of the histogram, the reflected lightcomponents from the target object 2 and the non-target object 3 arecombined in the signal obtained by the signal light receiving unit 21 ofthe optical sensor 1, as illustrated in FIG. 2. Thus, a histogramindicating the result of counting the signals for each bin has adistorted shape.

In other words, in FIG. 2, because the position of the center of gravityof the histogram shifts, the class in which the frequency peaks alsoshifts. In this histogram, since the time from the emission of light tothe reception of the reflected light, which corresponds to the class,cannot be accurately specified, highly accurate distance calculationcannot be performed.

In the present embodiment, in order to correspond to the shift of theposition of the center of gravity, a degree of distortion of thehistogram in which a plurality of objects obtained by the optical sensor1 are mixed is determined to be skewness, and correction according tothe skewness is applied at the time of distance calculation to improvethe accuracy of the distance calculation.

Description of Skewness

The “skewness” is a value indicating how far a distribution map(histogram) is distorted from a normal distribution as a statisticalmethod. As illustrated in FIG. 2, the skewness is a positive value (forexample, 0.76) in a histogram that leans forward with a tail furtherbackward. Furthermore, the skewness is a negative value (for example,−0.76) in a histogram that leans backward with a tail further forward.The skewness is an index in which the absolute value of the indexbecomes larger as each tendency becomes stronger.

A degree of collapse of the histogram shape is quantified with askewness β₁ ^(1/2), and the distance value to the object is correctedusing the β₁ ^(1/2) to detect the target object. β₁ ^(1/2) is calculatedby Equation (1). In this equation, b is a section number of thehistogram bin interval (measurement interval). n_(b) is a signal amountin each bin (a count value of the time stamp per unit time that isshorter than the measurement interval). μ is an average value of thesection number b. In other words, μ is a section number in which afrequency of occurrence of the signal is greatest. σ is a positivesquare root of a dispersion of the section number b (in other words,standard deviation).

$\begin{matrix}\left\lbrack {{Equation}1} \right\rbrack &  \\{\beta_{1}^{1/2} = \frac{\sum_{b}{n_{b}\left( {b - \mu} \right)}^{3}}{\sum_{b}{n_{b}\sigma^{3}}}} & {{Equation}(1)}\end{matrix}$

By correcting the distance value in a direction of the target object 2by using the skewness β₁ ^(1/2), distance calculation with further highaccuracy can be performed. Furthermore, a threshold value related todetermination in object detection is determined by using the skewness β₁^(1/2), and thus object detection that is less likely to be influencedby the non-target object can be performed.

Processing of Optical Sensor 1

FIG. 3 is a flowchart illustrating processing of the optical sensor 1according to the present embodiment. The processing of the opticalsensor 1 will be described in accordance with FIG. 3.

Step S11: Generation Step

In the optical sensor 1, the histogram generation unit 25 generates ahistogram based on a signal from the signal light receiving unit 21configured to receive signal light outside the optical sensor 1.Furthermore, the histogram generation unit 25 generates a histogrambased on a signal from the reference light receiving unit 23 configuredto receive reference light inside the optical sensor 1.

Step S12

The calculation unit 26 subtracts a position of the center of gravity ofthe histogram based on the reference light from a position of the centerof gravity of the histogram based on the signal light, generated in stepS11. Thus, an origin position can be set in the histogram. In thepresent embodiment, this histogram is used in steps S13 and S14.

Step S13: First Calculation Step

The calculation unit 26 calculates skewness by using Equation (1) fromthe histogram of the result in which the origin position is set in stepS12.

Step S14: Second Calculation Step

The calculation unit 26 calculates the distance between the opticalsensor 1 and the target object 2 with reference to the histogram of theresult in which the origin position is set in step S12, the skewnesscalculated in step S13, and a predetermined distortion coefficient.Specifically, the calculation unit 26 calculates the distance from thehistogram and corrects the distance by using the skewness and thedistortion coefficient. For example, as in Equation (2), the calculationunit 26 calculates a distance value Range obtained by multiplying aposition of the center of gravity G_(hist) of the histogram by ahistogram width W, and corrects the distance value Range with a valueobtained by multiplying the skewness β₁ ^(1/2) by a distortioncoefficient K.

[Equation 2]Range=G _(hist) ×W+β ₁ ^(1/2) ×K  Equation (2)

The distortion coefficient K may be, for example, an experimentallydetermined numerical value, or may be appropriately set according to ameasurement range or the like of the optical sensor 1.

As described above, the optical sensor 1 can calculate the distance tothe target object 2 with high accuracy.

As described above, a case has been described in which the referencelight is used as the origin information, but the present embodiment isnot limited this example. For example, as a modification, components(for example, the reference light receiving unit 23 and the second TDC24) and steps (for example, generation of a histogram based on thereference light (the second half of step S11), setting of the origin(step S12), and the like) associated with the reference light from thelight-emitting element 13 may be omitted, and a histogram based on thesignal light generated in the first half of step S11 may be used insteps S13 and S14.

Example 1

FIG. 4 is a graph showing a specific example according to the presentembodiment. In the example illustrated in FIG. 4, the target object 2 istransparent and is mounted on the non-target object 3 serving as afloor.

In the example illustrated in FIG. 4, the optical sensor 1 according tothe present embodiment determines distortion of a histogram in which thereflected light of the target object 2 and the reflected light of thenon-target object 3 are mixed, and corrects the distance value Range tothe target object 2 by using Equation (3).

[Equation 3]Range=G _(hist)×7.5+β₁ ^(1/2)×13.9  Equation (3)

In this equation, G_(hist) is a position of the center of gravity of thehistogram. 7.5 is a histogram width. 13.9 is a distortion coefficient.

Note that distance calculation by a known method is illustrated inEquation (4).

[Equation 4]Range=G _(hist)×7.5  Equation (4)

The calculation unit 26 (second calculation unit) of the optical sensor1 calculates the distance between the optical sensor 1 and the targetobject 2 by using the center of gravity of the histogram and a valueobtained by multiplying the skewness by the distortion coefficient.Specifically, as in the Equation (3), the calculation unit 26 adds aproduct obtained by multiplying the skewness by the distortioncoefficient to a distance Range in Equation (4).

The skewness β₁ ^(1/2) in the mixed state in FIG. 4 is −1.06, and notonly the signal of the target object 2 but also the signal of thenon-target object 3 are mixed. Thus, it can be determined that thehistogram is dominated by the signal of the non-target object 3 with thetail further forward.

A calculated distance value obtained by correcting the position of thecenter of gravity by an amount of the tail according to Equation (3) isa position indicated by A′1, and thus it is possible to calculate adistance closer to a theoretical distance value P1 between the opticalsensor 1 and the target object 2 than a position of a calculateddistance value A1 in the mixed state before correction by the Equation(4) even in a case of the transparent target object 2 which is stronglyinfluenced by the reflection in the target object 2 and the reflectionby the non-target object 3 and is intrinsically difficult to detect thedistance.

Second Embodiment

A second embodiment of the present disclosure will be described below.Note that, for convenience of explanation, components having functionsidentical to those in the first embodiment will be denoted by the samereference numerals, and descriptions of those components will beomitted.

In a case where the target object 2 is detected by the optical sensor 1,when the optical sensor 1 is close to the target object 2, there is atendency that a signal amount from the target object 2 greatly changes,while a signal amount from the non-target object 3 does not change muchin relation to the light received in the optical sensor 1. In thepresent embodiment, the histogram generation unit 25 generates a firsthistogram corresponding to the target object 2 and the non-target object3 before the optical sensor 1 moves, and a second histogramcorresponding to the target object 2 and the non-target object 3 afterthe optical sensor 1 moves. The calculation unit (second calculationunit) 26 calculates the distance between the optical sensor 1 and thetarget object 2 with reference to a difference between the firsthistogram and the second histogram. Since the signal component of thetarget object 2 remains in the difference, the distance can becalculated with high accuracy.

FIG. 5 is a graph showing histograms of distances between the opticalsensor 1 and the target object 2 and between the optical sensor 1 andthe non-target object 3 according to the present embodiment, where thehorizontal axis represents a section number of a bin interval(measurement interval), and the vertical axis represents the signalamount received from the target object and/or the non-target object. Asshown in FIG. 5, a histogram 1 (Hist 1) is a histogram in a state wherethe target object and the non-target object are mixed before moving andis indicated by a solid line to which plot marks are not added. Ahistogram 2 (Hist 2) is a histogram in a state where the target objectand the non-target object are mixed after moving and is indicated by adotted line to which plot marks are not added. A histogram 3 (Hist 3) isa histogram generated by subtracting the histogram 1 from the histogram2 and is indicated by a dashed-dotted line to which square plot marksare added.

In FIG. 5, when the histogram 1 and the histogram 2 are compared, thehistogram 2 when the distance between the optical sensor 1 and thetarget object 2 is shorter due to the movement of the optical sensor 1or the target object 2 has a larger signal amount of the target object 2than that of the histogram 1 when the distance is longer before moving.As shown in the lines with triangles in FIG. 5, it can be seen thatthere is a large difference in the signal amount received from thetarget object 2 by the optical sensor 1 before and after the movement.This is because the intensity of the light is inversely proportional tothe square of the distance from the light source, and thus the shorterthe distance, the larger the signal amount indicating the intensity ofthe light. On the other hand, as shown in the lines with circles in FIG.5, the signal amount received from the non-target object 3 by theoptical sensor 1 does not change much before and after the movement. Inaddition, since the signal amount is different for each of the targetobject 2, the non-target object 3, and the mixed state of the targetobject 2 and the non-target object 3, the histogram in the mixed statetends to have a distorted shape, as shown in FIG. 5.

Thus, the histogram 3 is generated by subtracting the histogram 1 fromthe histogram 2 shown in FIG. 5. As a result, the distance between theoptical sensor 1 and the target object 2 can be calculated with highaccuracy.

When the optical sensor 1 is close to the target object 2, the signalamount of the target object 2 close to the optical sensor 1 increasesgreatly before and after the optical sensor 1 moves as shown by thelines with the triangles in FIG. 5, but the signal amount of thenon-target object 3 that is separated from the optical sensor 1 does notchange much as shown the lines with the circles in FIG. 5.

Accordingly, due to the subtraction described above, a signal componentof the non-target object 3 is substantially canceled and a small signalamount is subtracted from a large signal amount in the signal componentof the target object 2, and thus a large amount of the signal componentof the target object 2 remains. As a result, the distance can becalculated with high accuracy. Note that, the calculation unit 26 neednot necessarily always subtract the histogram before moving from thehistogram after moving, and may subtract a histogram having a smallersignal amount from a histogram having a larger signal amount among thehistogram before moving and the histogram after moving.

Processing of Optical Sensor 1 FIG. 6 is a flowchart illustratingprocessing of the optical sensor 1 according to the present embodiment.The processing of the optical sensor 1 will be described in accordancewith FIG. 6.

Step S21 Before the target object 2 moves, in the optical sensor 1, thehistogram generation unit 25 generates a histogram based on a signalfrom the signal light receiving unit 21 configured to receive a signallight outside the optical sensor 1. Furthermore, the histogramgeneration unit 25 generates a histogram based on a signal from thereference light receiving unit 23 configured to receive reference lightinside the optical sensor 1. Then, the calculation unit 26 subtracts aposition of the center of gravity of the histogram based on thereference light from a position of the center of gravity of thegenerated histogram based on the signal light. As a result, in thehistogram 1 before moving (Hist1: solid line in the mixed state beforemoving in FIG. 5), the origin position can be set.

Step S22

After the target object 2 moves, in the optical sensor 1, the histogramgeneration unit 25 generates a histogram based on the signal from thesignal light receiving unit 21 configured to receive the signal lightoutside the optical sensor 1. Furthermore, the histogram generation unit25 generates the histogram based on the signal from the reference lightreceiving unit 23 configured to receive reference light inside theoptical sensor 1. Then, the calculation unit 26 subtracts the positionof the center of gravity of the histogram based on the reference lightfrom the position of the center of gravity of the generated histogrambased on the signal light. As a result, in the histogram 2 after moving(Hist2: broken line in the mixed state after moving in FIG. 5), theorigin position can be set.

Step S23

The calculation unit 26 calculates the skewness from the histogram 1obtained in step S21 by using Equation (1) of the first embodiment.

Step S24

The calculation unit 26 subtracts the histogram 1 obtained in step S21from the histogram 2 obtained in step S22, and generates the histogram 3for signal extraction (Hist 3: a dashed-dotted line of the signaldifference of the target detection object in FIG. 5).

In this case, in a case where the non-target object 3 is present behindthe target object 2, the position of the non-target object 3 isconsidered to be substantially constant and the signal amount is alsosubstantially constant as shown in the lines representing the non-targetobject before and after the movement in FIG. 5. Furthermore, the signalamount representing the intensity of the light is inversely proportionalto the square of the distance. Accordingly, by subtracting the histogram1 before moving in the mixed state from the histogram 2 after moving inthe mixed state, the histogram 3 for signal extraction schematicallyserving as a histogram after moving of only the target object 2 isgenerated.

Step S25

The calculation unit 26 calculates the distance value between theoptical sensor 1 and the target object 2 from the histogram 3 for signalextraction generated in step S24, and corrects the distance value byusing the skewness calculated in step S23 and a predetermined distortioncoefficient.

Example 2

FIG. 7 is a graph showing a specific example according to the presentembodiment. As the specific example of the present embodiment, a casewill be described in which the signals before and after movement aresubtracted in the histogram in which the target object 2 and thenon-target object 3 are mixed.

As illustrated in FIG. 7, as compared with before the subtraction, afterthe subtraction, the histogram having a shape closer to the histogram ofonly the target object 2 is obtained by excluding the tail component,and thus the target object component is dominant.

The center of gravity is at a position of 7.3 bin when calculated basedon a typical histogram, but the center of gravity is at a position of5.7 bin when calculated based on the histogram after the subtraction,which is a value close to the ideal value 3.7 bin in the presentexample.

A distance indicated by A2 is obtained when the calculation is performedby a known method based on the typical histogram. In comparison withExample 1 in which correction is applied using the skewness and thedistance indicated by A′1 in FIG. 4 is obtained, the distance indicatedby A′2 shown in FIG. 7 is obtained by calculating the Equations (1) and(2) based on the histogram after the difference, which is effective inimproving accuracy (see FIG. 7).

In the equation, b is a section number of a bin interval (measurementinterval) of the histogram, and n_(b) is the signal amount in 1 bin. μis an average value in the section b. σ is a positive square root of adispersion in the section b. G_(hist) is a position of the center ofgravity of the histogram. 7.5 is a histogram width. 13.9 is a distortioncoefficient.

Third Embodiment

A third embodiment of the present disclosure will be described below.Note that, for convenience of explanation, components having functionsidentical to those in the first and second embodiments will be denotedby the same reference numerals, and descriptions of those componentswill be omitted.

FIG. 8 is a block diagram illustrating a configuration of an opticalsensor 1 a according to the present embodiment. The optical sensor 1 afurther includes an information acquisition unit (acquisition unit) 30configured to acquire range-related information related to a range inwhich the target object (object) 2 may be present, and the calculationunit 26 calculates the skewness with reference to the range-relatedinformation. Specifically, the calculation unit 26 sets an element range(the range of Σ in Equation (1) described above) of the histogram usedfor calculating the skewness to correspond to the range in which thetarget object 2 may be present. As a result, accuracy of the distance tobe calculated is improved.

In one aspect, the information acquisition unit 30 may be configured toreceive input of the range-related information from a user or anotherdevice. Examples of the range-related information include an assumedinitial positional relationship between the optical sensor 1 a and thetarget object 2, a moving distance of the optical sensor 1 a or thetarget object 2, and a measurement range required for the optical sensor1 a. Note that the measurement range is a range that is arbitrarilydetermined according to the application of the optical sensor 1 a, andis a range overlapping a detection range that is defined by performanceof the optical sensor 1 a.

In one aspect, the information acquisition unit 30 may detect theposition of the non-target object 3 such that the position of the targetobject 2 is defined, and may acquire the range-related information basedon the position of the non-target object 3. For example, in a case wherethe target object 2 is disposed on the non-target object 3, or thetarget object 2 is disposed in the non-target object 3, the informationacquisition unit 30 can acquire the range-related information related tothe range in which the target object 2 may be present based on theposition of the non-target object 3. For example, during calibration ofthe optical sensor 1 a, the optical sensor 1 a may measure distance tothe non-target object 3 instead of the target object 2, and theinformation acquisition unit 30 may acquire the range-relatedinformation based on the result.

According to the configuration described above, the calculation unit 26sets the element range (the range of E in Equation (1) described above)of the histogram used for calculating the skewness to correspond to therange in which the target object 2 may be present, and thus theinfluence of reflected light from the non-target object 3 presentoutside the range where the target object 2 may be present can beeliminated as much as possible when the skewness is calculated. As aresult, accuracy of the distance to be calculated is improved.

Fourth Embodiment

A fourth embodiment of the present disclosure will be described below.Note that, for convenience of explanation, components having functionsidentical to those in the first to third embodiments will be denoted bythe same reference numerals, and descriptions of those components willbe omitted.

In the present embodiment, similar to the third embodiment, the opticalsensor 1 a further includes the information acquisition unit(acquisition unit) 30 configured to acquire the range-relatedinformation related to the range in which the target object (object) 2may be present. The calculation unit 26 of the optical sensor 1 acalculates distance by using the distortion coefficient corresponding tothe information related to the range in which the target object 2 may bepresent. As a result, accuracy of the distance to be calculated isimproved.

The optical sensor 1 a typically has a detection range having a centralaxis extending from the optical sensor 1 a. The detection range may berepresented as a substantially conical shape, or may be represented as asubstantially three dimensional shape due to the shape of a windowprovided on the optical sensor 1 a. In a case where the optical sensor 1a is brought closer to the target object 2 and the non-target object 3,the detection range of the optical sensor 1 a is limited as comparedwith before being brought close, and the ratio of space occupied by themixed object of the non-target object 3 and the target object 2 in thedetection range increases. Thus, in a case where the optical sensor 1 aand the target object 2 are close to each other, the distortioncoefficient is set so as to increase the distortion correction amountwhen the calculation unit 26 calculates the distance, and thus asolution close to the actual distance is obtained.

In a case where the target object 2 is disposed on the non-target object3 as an example, the information acquisition unit 30 may acquire thedistance between the optical sensor 1 a and the non-target object 3 asthe range-related information, and the calculation unit 26 may set K inEquation (2) described above to K1 when the distance between the opticalsensor 1 a and the non-target object 3 is less than a threshold value,and may set K in Equation (2) described above to K2 (K1>K2) when thedistance between the optical sensor 1 a and the non-target object 3 isequal to the threshold value or more. In other words, the calculationunit 26 can set the distortion coefficient such that the distortioncoefficient increases as the range in which the target object 2 may bepresent becomes closer to the optical sensor 1 a. As the range in whichthe target object 2 may be present becomes closer to the optical sensor1 a, the calculation unit 26 may change the distortion coefficientstepwise in two steps or more, or may gradually increase the distortioncoefficient. The value of the distortion coefficient set by thecalculation unit 26 may be, for example, experimentally determined.

Fifth Embodiment

A fifth embodiment of the present disclosure will be described below.Note that, for convenience of explanation, components having functionsidentical to those in the first to fourth embodiments will be denoted bythe same reference numerals, and descriptions of those components willbe omitted.

In the present embodiment, the optical sensor 1 includes, as the signallight receiving unit 21, a plurality of light-receiving elements havingdifferent detection angles from each other. Accordingly, the pluralityof light-receiving elements detect signal light from the target object 2and the non-target object 3 at different detection angles from eachother.

According to the configuration described above, by detecting the signallight from the target object 2 and the non-target object 3 at differentdetection angles, the distance between the optical sensor 1 and thetarget object 2 can be calculated with high accuracy. Furthermore, thelight-emitting elements 13 or the signal light receiving units 21 havedifferent incident angles or different detection angles from each other,and thus the accuracy of the detection distance can be selectivelyincreased.

An example of edge detection of the target object 2 using the presentembodiment is given. In a case where the positional relationship of thetarget object 2 is not fixed and the position of the target object 2with respect to the optical sensor 1 is not constrained, because theoptical sensor 1 includes the signal light receiving units 21 havingdifferent detection angles from each other, the distance can becalculated by utilizing the signals of the light-receiving elementsappropriately capturing the target object 2. As a result, resistance topositional variation of the target object 2 can be improved. In otherwords, since the optical sensor 1 includes the plurality oflight-receiving elements having different detection angles from eachother, even when the position of the target object 2 varies, anylight-receiving element receives the light at an appropriate angle andthe signals of the light-receiving elements are used, and thus the highaccuracy of the distance calculation can be maintained. Theconfiguration of the present embodiment is extremely effective since therange of the target object 2 in which the distance can be calculatedwith high accuracy is wider than that of a configuration including asingle-angle light-receiving element.

Sixth Embodiment

A sixth embodiment of the present disclosure will be described below.Note that, for convenience of explanation, components having functionsidentical to those in the first to fifth embodiments will be denoted bythe same reference numerals, and descriptions of those components willbe omitted.

The present embodiment is applied to, for example, an electronic deviceincluding an optical sensor 1 b. The electronic device includes, forexample, a water purifier or a surveying instrument that performs aspecific operation in a case where the target object is within apredetermined distance, but is not limited to these electronic devices.

FIG. 9 is a block diagram illustrating a configuration of the opticalsensor 1 b according to the present embodiment. As can be seen bycomparing FIG. 1 and FIG. 9, the optical sensor 1 b further includes adetermination unit 27 compared to the optical sensor 1. Thedetermination unit 27 determines whether the target object 2 is detectedby comparing a distance between the optical sensor 1 b and the targetobject 2 calculated by the calculation unit (second calculation unit) 26with a threshold value of the distance. Specifically, the determinationunit 27 determines that the target object 2 is detected in a case wherethe distance between the optical sensor 1 b and the target object 2 isequal to the threshold value or less.

FIG. 10 is a graph showing a change in a signal amount detected by theoptical sensor 1 b due to a difference in the distance between theoptical sensor 1 b according to the present embodiment and the targetobject 2. As illustrated in FIG. 10, as the optical sensor 1 b and thetarget object 2 become closer to each other, the signal amountincreases. On the other hand, as the optical sensor 1 b and the targetobject 2 separate from each other, the signal amount decreases. When thesignal amount decreases, the difference between the signal light and thesurrounding noise light decreases, and thus noise light cannot beignored. The signal amount detected by the optical sensor 1 b may varydepending on magnitudes of reflectivity of the target object 2 and thenon-target object 3.

Because of this characteristic, the calculation unit (first calculationunit) 26 may adjust the threshold value of the distance in accordancewith the intensity of the reflected light from the target object 2. Forexample, in a case where a detection signal amount is large (reflectedlight is strong), the SN ratio is good and so the calculation unit 26sets a threshold value that is close to an ideal distance for performinga predetermined operation. On the other hand, in a case where thedetection signal amount is small (reflected light is weak), there is apossibility that the distance is calculated to be longer by the amountof distance to a light source of the noise light due to the influence ofthe noise light, and thus the calculation unit 26 sets the thresholdvalue to be larger than the above-described ideal distance. As a result,resistance to noise light can be improved.

Processing of Optical Sensor 1 b

FIG. 11 is a flowchart illustrating processing of the optical sensor 1 baccording to the present embodiment. The processing of the opticalsensor 1 b will be described in accordance with FIG. 11.

Step S61

Before the target object 2 moves, in the optical sensor 1 b, thehistogram generation unit 25 generates a histogram based on a signalfrom the signal light receiving unit 21 configured to receive signallight outside the optical sensor 1 b. Furthermore, the histogramgeneration unit 25 generates the histogram based on a signal from thereference light receiving unit 23 configured to receive reference lightinside the optical sensor 1 b. Then, the calculation unit 26 subtractsthe position of the center of gravity of the histogram based on thereference light from the position of the center of gravity of thegenerated histogram based on the signal light. Thus, an origin positioncan be set in a histogram 1 before moving.

Step S62

After the target object 2 moves, in the optical sensor 1 b, thehistogram generation unit 25 generates a histogram based on a signalfrom the signal light receiving unit 21 configured to receive the signallight outside the optical sensor 1 b. Furthermore, the histogramgeneration unit 25 generates a histogram based on a signal from thereference light receiving unit 23 configured to receive reference lightinside the optical sensor 1 b. Then, the calculation unit 26 subtractsthe position of the center of gravity of the histogram based on thereference light from the position of the center of gravity of thegenerated histogram based on the signal light. Thus, an origin positioncan be set in a histogram 2 after moving.

Step S63

The calculation unit 26 adjusts a threshold value serving as a distancevalue for detection determination in accordance with the signal amountsof the histogram 1 obtained in step S61 and the histogram 2 of theresult obtained in step S62. Note that the calculation unit 26 mayadjust the threshold value in accordance with not only the signal amountbut also a height (or movement amount) of the optical sensor 1 b. Inthis case, the optical sensor 1 b further includes the informationacquisition unit 30. Then, the calculation unit 26 acquires the heightof the optical sensor 1 b (or the movement amount of the optical sensor1 b) from the information acquisition unit 30. Then, the calculationunit 26 adjusts the threshold value to be larger as the position of theoptical sensor 1 b separates from the assumed light source of the noiselight (for example, the floor surface serving as the light source of thereflected light).

Step S64

The calculation unit 26 calculates each skewness from the histogram 1obtained in step S61 and the histogram 2 of the result obtained in stepS62 by using Equation (1) of the first embodiment.

Step S65

The calculation unit 26 subtracts the histogram 1 obtained in step S61from the histogram 2 obtained in step S62, and generates the histogram 3for signal extraction.

Step S66

The calculation unit 26 corrects the distortion of the histogram 3 forsignal extraction generated in step S65 by using the skewness calculatedin step S64 and the predetermined distortion coefficient, and calculatesthe distance value between the optical sensor 1 b and the target object2 from the histogram 3.

Step S67

The determination unit 27 determines detection or non-detection of thetarget object 2 by comparing the distance value calculated in step S66with the threshold value adjusted in step S63.

Specifically, the determination unit 27 determines whether the distancevalue calculated in step S66 is equal to or less than the thresholdvalue adjusted in step S63. In a case where the distance value is equalto or less than the threshold value, the determination unit 27determines that the target object 2 is detected. In a case where thedistance value is greater than the threshold value, the determinationunit 27 determines that the target object 2 is not detected. Note that,even when the distance value is equal to or less than the thresholdvalue, the determination unit 27 may invalidate the detection of thetarget object 2 in a case where the signal amount of the histogram 2 isless than the signal amount of the histogram 1 despite the signalsupposedly being large by the distance square law of light when thedistance to the target object 2 is small.

Example 3

In order to more specifically illustrate the effect of the presentembodiment, a case will be described in which tip detection of targetobjects 2 made of different materials from each other is performed in anenvironment in which the target object 2 and the non-target object 3 aremixed.

FIG. 12 is a graph showing changes in signal amounts and changes incalculated distance values when the optical sensor 1 b is movingrelative to target objects 2 made of different materials. In FIG. 12,the distance represented by the dashed-dotted line is ideallycalculated. A material 2 is a material having higher reflectivity than amaterial 1. Note that the reflectivity of the target object 2 changeseven depending on the color and shape in addition to the material of thetarget object 2.

In a case where the optical sensor 1 b and the target object 2 are closeto each other, the influence of the noise is small, and thus the opticalsensor 1 b can easily calculate a more accurate distance value of thetarget object 2. As indicated by the broken line in FIG. 12, the closerthe optical sensor 1 b and the target object 2 are to each other (thesmaller the distance on the horizontal axis), the more the signal amountincreases in a shape close to the square, and thus it can be seen thatthere is less influence of noise or the like and that the reflectedlight is captured from the target object 2.

On the other hand, in a case where the optical sensor 1 b and the targetobject 2 are separated from each other, or in a case where the materialsof the target objects 2 are different from each other, the influence ofnoise is large, and thus the optical sensor 1 b likely to calculate adistance value greatly influenced by the non-target object 3. Asindicated by the line with white circle plot marks in FIG. 12, sincerise of the signal amount does not occur until the distance becomesshort for the material 1 having a low reflectivity as compared with thematerial 2 having a high reflectivity, it can be seen that the influenceof noise is large. As indicated by the line with white triangle plotmarks in FIG. 12, since the change in the signal amount at a positionhaving a long distance is not the shape of the square even in the caseof the material 2 having the high reflectivity, it can be seen that theinfluence of noise is large.

Thus, by adjusting the threshold value of the detection distance inaccordance with the signal amount received by the optical sensor 1 b,the optical sensor 1 b functions to switch between the detectiondistance between the case where the target object 2 is moreappropriately detected and the case where the target object 2 is notdetected, and the object can be detected at an appropriate positionwhich is resistant to the noise and is less likely to be influenced bythe difference in materials.

As shown in FIG. 12, the change in the calculated distance for thematerial 1 having low reflectivity (solid line with circles in thegraph) is not a linear transition as compared with the change in thecalculated distance for the material 2 having high reflectivity (solidline with triangles in the graph). Even when actual distances are thesame, different calculated distances between the material 1 and thematerial 2 are indicated.

Thus, since the magnitude of the signal amount varies in accordance withthe target object 2, the calculation unit 26 may switch the thresholdvalue in accordance with the magnitude of the signal amount. In oneaspect, in a case where the signal amount is equal to or greater than apredetermined amount, the calculation unit 26 may use a shorterthreshold value as the threshold value for the calculated distance valuethan when the signal amount is less than the predetermined amount.

For example, in the example shown in FIG. 12, in a case where thecalculation unit 26 (i) sets the threshold value for the calculateddistance value to 72 mm when the signal amount is less than 300 and (ii)sets the threshold value for the calculated distance value to 55 mm whenthe signal amount is 300 or greater, the determination unit 27 (i)determines that the calculated distance exceeds the threshold value whenthe target object 2 of the material 1 having low reflectivity isactually located at a distance of 55 mm and (ii) determines that thecalculated distance exceeds the threshold value when the target object 2of the material 2 having high reflectivity is actually located at adistance of 60 mm. As a result, the difference between the actualdistances when the determination unit 27 determines that the calculateddistance exceeds the threshold value can be reduced as compared with acase where a constant threshold value is used. Thus, with respect to thetarget objects 2 having different materials from each other, the opticalsensor 1 b can determine that the calculated distance has exceeded thethreshold value at a close distance even when the materials aredifferent.

Implementation Example by Software

Functions of the optical sensor 1, 1 a, and 1 b (hereinafter referred toas “optical sensor”) can be implemented by a program for causing acomputer to function as the optical sensor and for causing the computerto function as each control block (specifically, the histogramgeneration unit 25, the calculation unit 26, and the determination unit27) of the optical sensor.

In this case, the optical sensor includes a computer including at leastone control device (for example, a processor) and at least one storagedevice (for example, a memory) as hardware for executing the program. Byexecuting the program with the control device and the storage device,each function described in the above-described each embodiment isachieved.

The program may be stored in one or a plurality of computer-readablenon-transitory storage medium. The storage medium may or may not beincluded in the device described above. In the latter case, the programmay be supplied to the device via any transmission medium, wired orwireless.

Furthermore, some or all of the functions of each control block can beimplemented by a logic circuit. For example, an integrated circuit inwhich the logic circuit functioning as each control block describedabove is formed is also included within the scope of the presentdisclosure. In addition to this, it is also possible to realize thefunction of each control block described above by, for example, aquantum computer.

Supplement

An optical sensor according to a first aspect of the present disclosureis an optical sensor including a light-emitting element configured toemit light in a region where an object is present, a light-receivingelement configured to receive reflected light from the object, ageneration unit configured to generate a histogram indicating arelationship between a time from emission of the light by thelight-emitting element to reception of the reflected light by thelight-receiving element and an intensity of the reflected light receivedby the light-receiving element, a first calculation unit configured tocalculate skewness of the histogram, and a second calculation unitconfigured to calculate a distance between the optical sensor and theobject with reference to the histogram and the skewness.

According to the configuration described above, since the histogram andthe skewness are referred to, the distance to the object can becalculated with high accuracy even when a plurality of the objects arepresent.

In the optical sensor according to a second aspect of the presentdisclosure, in the first aspect, the second calculation unit maycalculate the distance by using a center of gravity of the histogram anda value obtained by multiplying the skewness by a distortioncoefficient.

According to the configuration described above, since the center ofgravity of the histogram and the value obtained by multiplying theskewness by the distortion coefficient are used, the distance to theobject can be calculated with further high accuracy.

In the optical sensor according to a third aspect of the presentdisclosure, in the first or second aspect, the histogram may include afirst histogram corresponding to the object before moving and a secondhistogram corresponding to the object after moving, the generation unitmay generate each of the first histogram and the second histogram, andthe second calculation unit may calculate the distance with reference toa difference between the first histogram and the second histogram.

According to the configuration described above, by referring to thedifference between the histograms before and after movement when theoptical sensor moves, it is possible to leave a large amount of acomponent of the object close to the optical sensor and substantiallycancel a component of the object separated from the optical sensor,among the reflected light component of the object, and thus, thedistance to the object to be measured close to the optical sensor can becalculated with high accuracy.

The optical sensor according to a fourth aspect of the presentdisclosure, in any one of the first to third aspects, may include anacquisition unit configured to acquire information related to a rangehaving possibility that the object is present, wherein the firstcalculation unit may calculate the skewness with reference to theinformation related to the range having the object is present.

According to the configuration described above, since the skewness iscalculated with reference to the range in which the object may bepresent, the skewness is appropriately determined, and thus the accuracyof the distance corrected using the skewness is improved.

The optical sensor according to a fifth aspect of the presentdisclosure, in the second aspect, may include an acquisition unitconfigured to acquire information related to a range having possibilitythat the object is present, wherein the second calculation unit may usethe distortion coefficient corresponding to the information related tothe range having possibility that the object is present.

According to the configuration described above, since the distance iscalculated using the distortion coefficient corresponding to the rangein which the object may be present, the accuracy of the distance isimproved.

The optical sensor according to a sixth aspect of the presentdisclosure, in any one of the first to third aspects, may include aplurality of the light-receiving elements having different detectionangles from each other.

According to the configuration described above, since the plurality oflight-receiving elements have different detection angles from eachother, the accuracy of the detection distance can be selectivelyincreased.

The optical sensor according to a seventh aspect of the presentdisclosure, in any one of the first to third aspects, may include adetermination unit configured to determine whether the object isdetected by comparing the distance calculated by the second calculationunit and a threshold value of the distance.

According to the configuration described above, it is possible todetermine that the target object has been detected when the distance isequal to the threshold value or less.

In the optical sensor according to an eight aspect of the presentdisclosure, in the seventh aspect, the first calculation unit may adjustthe threshold value in accordance with the intensity of the reflectedlight.

According to the configuration described above, since the thresholdvalue of the distance is adjusted in accordance with the intensity ofthe reflected light, resistance to noise light can be improved.

An electronic device according to a ninth aspect of the presentdisclosure includes the optical sensor according to any one of the firstto eighth aspects.

According to the configuration described above, since the histogram andthe skewness are referred to, the distance to the object can becalculated with high accuracy even when a plurality of the objects arepresent.

A distance calculation method according to a tenth aspect of thedisclosure is a distance calculation method for an optical sensorincluding a light-emitting element configured to emit light in a regionwhere an object is present and a light-receiving element configured toreceive reflected light from the object, the distance calculation methodincluding generating a histogram indicating a relationship between atime from emission of the light by the light-emitting element toreception of the reflected light by the light-receiving element and anintensity of the reflected light received by the light-receivingelement, performing a first calculation of calculating skewness of thehistogram, and performing a second calculation of calculating a distancebetween the optical sensor and the object with reference to thehistogram and the skewness.

According to the configuration described above, since the histogram andthe skewness are referred to, the distance to the object can becalculated with high accuracy even when a plurality of the objects arepresent.

The optical sensor according to each of the aspects of the presentdisclosure may be implemented by a computer. In this case, a controlprogram of the optical sensor that implements the optical sensordescribed above by a computer by causing the computer to function aseach unit (software element) provided in the optical sensor, and acomputer-readable storage medium that stores the control program alsofall within the scope of the present disclosure.

An aspect of the disclosure is not limited to each of theabove-described embodiments. It is possible to make variousmodifications within the scope of the claims. An embodiment obtained byappropriately combining technical elements each disclosed in differentembodiments falls also within the technical scope of the aspect of thedisclosure. Furthermore, technical elements disclosed in the respectiveembodiments may be combined to provide a new technical feature.

While there have been described what are at present considered to becertain embodiments of the invention, it will be understood that variousmodifications may be made thereto, and it is intended that the appendedclaims cover all such modifications as fall within the true spirit andscope of the invention.

What is claimed is:
 1. An optical sensor comprising: a light-emittingelement configured to emit light in a region where an object is present;a light-receiving element configured to receive reflected light from theobject; a generation unit configured to generate a histogram indicatinga relationship between a time from emission of the light by thelight-emitting element to reception of the reflected light by thelight-receiving element and an intensity of the reflected light receivedby the light-receiving element; a first calculation unit configured tocalculate skewness of the histogram; and a second calculation unitconfigured to calculate a distance between the optical sensor and theobject with reference to the histogram and the skewness.
 2. The opticalsensor according to claim 1, wherein the second calculation unitcalculates the distance by using a center of gravity of the histogramand a value obtained by multiplying the skewness by a distortioncoefficient.
 3. The optical sensor according to claim 1, wherein thehistogram includes a first histogram corresponding to the object beforemoving and a second histogram corresponding to the object after moving,the generation unit generates each of the first histogram and the secondhistogram, and the second calculation unit calculates the distance withreference to a difference between the first histogram and the secondhistogram.
 4. The optical sensor according to claim 1, furthercomprising: an acquisition unit configured to acquire informationrelated to a range having possibility that the object is present,wherein the first calculation unit calculates the skewness withreference to the information related to the range having possibilitythat the object is present.
 5. The optical sensor according to claim 2,further comprising: an acquisition unit configured to acquireinformation related to a range having possibility that the object ispresent, wherein the second calculation unit uses the distortioncoefficient corresponding to the information related to the range havingpossibility that the object is present.
 6. The optical sensor accordingto claim 1, further comprising: a plurality of the light-receivingelements having different detection angles from each other.
 7. Theoptical sensor according to claim 1, further comprising: a determinationunit configured to determine whether the object is detected by comparingthe distance calculated by the second calculation unit and a thresholdvalue of the distance.
 8. The optical sensor according to claim 7,wherein the first calculation unit adjusts the threshold value inaccordance with the intensity of the reflected light.
 9. An electronicdevice comprising: the optical sensor according to claim
 1. 10. Adistance calculation method for an optical sensor including alight-emitting element configured to emit light in a region where anobject is present and a light-receiving element configured to receivereflected light from the object, the distance calculation methodcomprising: generating a histogram indicating a relationship between atime from emission of the light by the light-emitting element toreception of the reflected light by the light-receiving element and anintensity of the reflected light received by the light-receivingelement; performing a first calculation of calculating skewness of thehistogram; and performing a second calculation of calculating a distancebetween the optical sensor and the object with reference to thehistogram and the skewness.
 11. A computer-readable non-transitorystorage medium storing a program for causing a computer to function asthe optical sensor according to claim 1, wherein the computer-readablenon-transitory storage medium stores a program for causing a computer tofunction as the generation unit, the first calculation unit, the secondcalculation unit.